struct Solution {}

fn main() {}

impl Solution {
    pub fn count_symmetric_integers(low: i32, high: i32) -> i32 {
        (low..=high).into_iter().filter(|e| Self::is_symmetric(e)).count().try_into().unwrap()
    }

    fn is_symmetric(num: &i32) -> bool {
        let str: String = num.to_string();
        if str.len() % 2 != 0 {
            return false;
        }
        let split_pos = str.len() / 2;
        Self::sum_pos(&str[0..split_pos]) == Self::sum_pos(&str[split_pos..])
    }

    fn sum_pos(s: &str) -> i32 {
        let mut ret: u32 = 0;
        s.to_string().chars().for_each(|e| ret += e.to_digit(10).unwrap());
        ret as i32
    }
}